<template>
    <div>
        <el-row :gutter="20">
            <el-col :span="6" :offset="0" v-for="i in 4" :key="i" v-if="panels.length === 0">
                <el-skeleton style="width:100%">
                    <template #template>
                        <el-card shadow="hover" class="border-0">
                            <template #header>
                                <div class="flex justify-between">
                                    <el-skeleton-item variant="text" style="width: 50%" />
                                    <el-skeleton-item variant="text" style="width: 30%" />
                                </div>
                            </template>
                            <el-skeleton-item variant="text" style="width: 35%;height:45px;" />
                            <el-divider />
                            <div class="flex justify-between text-sm text-gray-6 00">
                                <el-skeleton-item variant="text" style="width: 50%" />
                                <el-skeleton-item variant="text" style="width: 30%" />
                            </div>
                        </el-card>
                    </template>
                </el-skeleton>


            </el-col>

            <el-col :span="6" :offset="0" v-for="(item, index) in panels" :key="index">
                <el-card shadow="hover" class="border-0">
                    <template #header>
                        <div class="flex justify-between">
                            <span class="text-sm">{{ item.title }}</span>
                            <el-tag class="mx-1" :type="item.unitColor" effect="plain">
                                {{ item.unit }}
                            </el-tag>
                        </div>
                    </template>
                    <div class="text-3xl font-bold text-gray-500">
                        <!-- {{item.value}} -->
                        <CountTo :value="item.value"></CountTo>
                    </div>
                    <el-divider />
                    <div class="flex justify-between text-sm text-gray-6 00">
                        <span>{{ item.subTitle }}</span>
                        <span>{{ item.subValue }}</span>
                    </div>
                </el-card>
            </el-col>
        </el-row>
        <IndexNavs></IndexNavs> 
        <el-row :gutter="20"  class="mt-5">
            <el-col :span="12" >
                <IndexChart ></IndexChart>
            </el-col>
            <el-col :span="12" :offset="0">
                <IndexCart class="mb-5" title="店铺及商品提示" tip="店铺及商品提示" :btn="goods" ></IndexCart>
                <IndexCart title="交易提示" tip="需要立即处理的交易订单" :btn="order"></IndexCart>
            </el-col>
        </el-row>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { statistics1 ,statistics2} from "~/api/index.js"
import CountTo from "~/components/CountTo.vue"
import IndexNavs from "~/components/IndexNavs.vue"
import IndexChart from "~/components/IndexChart.vue"
import IndexCart from "~/components/IndexCart.vue"

const panels = ref([])
statistics1().then(res => {
    panels.value = res.panels
})


const goods=ref([])
const order=ref([])
statistics2().then((e)=>{
   goods.value=e.goods
   order.value=e.order
})

</script>
<style></style>